home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload Trio 2
/
Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO
/
dir31
/
in_out.zip
/
PHASOR.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-01-16
|
4KB
|
76 lines
;=============================================================================
;Example:
; TASM PHASOR.ASM
; TLINK/T PHASOR.OBJ
;
;If you are using the A86 assembler -
;place a "x" between bit 0 and the letter "B"
;in each of the binary numbers below....
;
;Example: 00000011xB
;==============================================================================
code_seg SEGMENT
ASSUME cs:code_seg, ds:code_seg, es:code_seg, ss:code_seg
ORG 100h
begin:
jmp start
;----------------------------------
;William Cravener ;Author
;520 North Stateline Rd
;Sharon, Pa 16146
;----------------------------------
message1 DB 'Press Esc to Quit', 0dh, 0ah, '$'
message2 DB 'Press any other key to Play$'
;----------------------------------
start PROC NEAR
mov ah, 9 ; DOS function number to print string
mov dx, OFFSET message1 ; the message
int 21h ; DOS interrupt
mov ah, 9 ; DOS function number to print string
mov dx, OFFSET message2 ; the message
int 21h ; DOS interrupt
begin2:
mov ah, 0 ; BIOS function wait for key press
int 16h ; BIOS interrupt
cmp ah, 1 ; Esc scan code
jz done ; do we stop ?
call phasor ; no call phasor sound
jmp begin2 ; go see if we do it again
done:
mov ax, 4c00h ; no exit back to DOS
int 21h ; DOS interrupt
start ENDP
;-------------------------------------
phasor PROC NEAR ; the above explained sound program
mov dx, 2000 ; number of times to repeat whole routine
mov bx, 1 ; start the sound frequency high
mov al, 10110110b ; the magic number
out 43h, al ; to initialize the port
next_frequency:
mov ax, bx ; move our frequency value into AX
out 42h, al ; copy LSB first
mov al, ah ; move MSB to AL
out 42h, al ; copy MSB second
in al, 61h ; must turn speaker ON
or al, 00000011b ; with this binary number
out 61h, al ; send it
mov cx, 100 ; 100 repeat loops
delay_loop:
loop delay_loop ; delay loop so we can hear sound
inc bx ; incrementing the value of BX lowers
; the frequency each time we repeat the
; whole routine
dec dx ; decrement repeat routine count
cmp dx, 0 ; is repeat count = to 0
jnz next_frequency ; if not do whole thing again
in al, 61h ; its time to turn speaker Off
and al, 11111100b ; binary number turns speaker off
out 61h, al ; send it
sti ; re-enable hardware interrupts
ret ; go see if user wants to do again
phasor ENDP
;----------------------------------
code_seg ENDS
END begin